# 1)  A = { 4, 5}
#     B = {4, 5, 6, 7, 8}
#      获取两个集合的交集，
#      并集
#      获取A中有，但是B 中没有的
#     检查A是否是B的子集
#      每个小题定义一个函数并且调用
# A = {1,2,3,4,5}
# B = {4,5,6,7,8}
# 交集
# def hs(C1,C2):
#     set1 = set()
#     for i in C1:
#         if i in C2:
#             set1.add(i)
#     return set1
# print(hs(A,B))
#并集
# def hs1(C3,C4):
#     set2 = set()
#     for n in C3:
#         if n in C3:
#             set2.add(n)
#     for m in C4:
#         if m in C4:
#             set2.add(m)
#     return set2
# print(hs1(A,B))
# 获取A中有，但是B 中没有的
# def hs2(C5,C6):
#     set3 = set()
#     for x in C5:
#         set3.add(x)
#         if x in C6:
#             set3.remove(x)
#     return set3
# print(hs2(A,B))
# 检查A是否是B的子集
# #1
# def hs3(C7,C8):
#         if C7 <= C8:
#             print("A是B的子集")
#         else:
#             print("A不是B的子集")
# print(hs3(A,B))

# #2
# def hs3(C7, C8):
#     for y in A:
#         if y not in B:
#             return False
#     return True
# print(hs3(A, B))
#
# 2）从列表中找出只出现一次的元素
# ls = [1,1,2,2,3,3,4,5]
# def hs4(C9):
#     ls1 = []
#     for j in C9:
#         if C9.count(j) == 1:
#             ls1.append(j)
#         return ls1
# print(hs4(ls))

# 3）找出一个列表中只出现一次的元素 不通过count()方法查找
ls = [1,1,2,2,3,3,4,5]
def hs5(lst):
    k = {}
    for i in lst:
        k[i] = k.get(i, 0) + 1
    for item in lst:
        if k[item] == 1:
            print(k)
    return k

hs5(ls)
# 总结：元组、列表、字典、集合的区别